﻿using System;
using Microsoft.Xna.Framework;

namespace SmlEngine.Timers
{
    /// <summary>
    /// Represents the event raised when an ITimer has completed a cycle.
    /// </summary>
    /// <param name="elapsed">The time elapsed since the last Tick.</param>
    /// <param name="totalElapsed">The total time elapsed since the timer was enabled.</param>
    public delegate void TickEventHandler<T>(T elapsed, T totalElapsed) where T : struct;

    public interface ITimer<TMeasure, TType> where TMeasure : struct
    {
        TMeasure Interval { get; set; }
        TMeasure TotalElapsed { get; }
        bool Enabled { get; set; }
        bool Repeats { get; set; }
        int RepeatCount { get; }
        int RepeatsRemaining { get; }

        Action<TType> Tick { get; set; }

        void Update(GameTime gameTime);
        void Start();
        void Start(bool reset);
        void Start(TMeasure interval);
        void Start(TMeasure interval, bool reset);
        void Stop();
        void Reset();
    }
}
